package myJs.api

import myJs.myPkg.MyFetch
import org.scalajs.macrotaskexecutor.MacrotaskExecutor.Implicits._
import upickle.default._

/**
 * Created by yz on 7/11/2022
 */
object PredictApi {

  import shared.pojo.Pojo.predict._

  val baseUrl = s"${Api.apiUrl}/user/predict"

  def predict(request: PredictData) = {
    val url = s"${baseUrl}/predict"
    MyFetch.postRnText(url = s"${url}", data = write(request), headers = Map("Content-Type" -> "application/json")).map { str =>
      read[Predict.Response](str)
    }
  }


}
